package cn.jboa.action;

import java.util.Map;

import cn.jboa.common.Constants;
import cn.jboa.entity.Employee;
import cn.jboa.util.PaginationSupport;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;

public class BaseAction<T> extends ActionSupport {
    protected Integer pageNo = 1;
    protected Integer pageSize = 5;
    protected PaginationSupport<T> pageSupport;

    protected Map<String, Object> getSession() {
        ActionContext actionContext = ActionContext.getContext();
        return actionContext.getSession();
    }

    protected Employee getLoginEmployee() {
        return (Employee) this.getSession().get(Constants.AUTH_EMPLOYEE);
    }

    public String getPositionForShort() {
        String s = this.getLoginEmployee().getSysPosition().getNameCn();
        if (Constants.POSITION_CASHIER.equals(s)) {
            return Constants.POSITION_CASHIER_EN;
        } else if (Constants.POSITION_FM.equals(s)) {
            return Constants.POSITION_FM_EN;
        } else if (Constants.POSITION_GM.equals(s)) {
            return Constants.POSITION_GM_EN;
        } else {
            return Constants.POSITION_STAFF_EN;
        }
    }

    public Integer getPageNo() {
        return pageNo;
    }

    public void setPageNo(Integer pageNo) {
        this.pageNo = pageNo;
    }

    public Integer getPageSize() {
        return pageSize;
    }

    public void setPageSize(Integer pageSize) {
        this.pageSize = pageSize;
    }

    public PaginationSupport<T> getPageSupport() {
        return pageSupport;
    }

    public void setPageSupport(PaginationSupport<T> pageSupport) {
        this.pageSupport = pageSupport;
    }

}
